<?php
/**
 * XiteCode Yes/No select widget
 *
 * Use:<br />
 * <code>
 * {YesNo id="id" [label="label"]}
 * </code>
 */

function smarty_function_YesNo($params, &$Smarty)
{
  $label    = '';
  $required = '';

  if (empty($params['id'])) {
    return '{YesNo} You must supply an id.';
  }

  if (!empty($params['required'])) {
    $required = ' class="required"';
  }

  if (!empty($params['label'])) {
    $label = '<label for="'.$params['id'].'"'.$required.'>'.$params['label'].'</label>';
  }

  return $label.'<select id="'.$params['id'].'" name="'.$params['id'].'"><option value="Y">Yes</option><option value="N">No</option></select><br />';
}

?>
